| Welcome | Data | Analyses | Discussion | Maps |
| Analyses | ||||||
|---|---|---|---|---|---|---|
| Urban Heat | All Areas | Portland | Tacoma | King County | iNaturalist | City Inventories |
library(tidyverse)
library(knitr)
library(kableExtra)
library(gghalves)
library(patchwork)
library(scales)
library(ggmap)
library(osmdata)
portland.parks <- read.csv('https://raw.githubusercontent.com/jmhulbert/redhot/main/data/Portland.Parks.Trees.AF.csv')
portland.streets <- read.csv('https://raw.githubusercontent.com/jmhulbert/redhot/main/data/Portland.Street.Trees.AF.csv')
seattle.combined <- read.csv('https://raw.githubusercontent.com/jmhulbert/redhot/main/data/Seattle.Trees.AF.csv')
portland.parks <- portland.parks[c(3,4,6,7,8,14,35,36,40,42:45)]
portland.parks <- portland.parks %>% mutate(city.space="Park")
portland.streets <- portland.streets[c(3,4,5,9,10:19)]
portland.streets <- portland.streets %>% mutate(city.space="Street") %>% rename(DBH=DIAMETER) %>% rename(Functional=FUNCTIONAL)
portland.combined <- full_join(portland.streets,portland.parks,by = join_by(OBJECTID, Condition, DN_AF1, lat, lon, DBH,city.space,Functional)) %>% mutate(city="Portland") %>% mutate(DN_AFc=DN_AF1)
portland.combined$DN_AF1 <- ((portland.combined$DN_AF1 * 1.8) +32)
seattle.combined <- seattle.combined[c(1:8,11:14,17:19)] %>% mutate(city="Seattle") %>% rename(GlobalID=GLOBALID)
seattle.streets <- seattle.combined %>% filter(Source.Department=="Seattle Department of Transportation") %>% mutate(city.space="Street")
seattle.parks <- seattle.combined %>% filter(Source.Department=="Seattle Parks and Recreation") %>% mutate(city.space="Park")
seattle.combined.back <- rbind(seattle.streets,seattle.parks)
Portland Categories - Dead Tops Protect from development: <85 Extra care: 85-88.5 Most concern: >88.5
King County Categories - Dead Tops Protect from development: <85 Extra care: 85-87.8 Most concern: >87.8
portland.protect <- portland.combined %>% filter(DN_AF1<85) %>% mutate(Category="Protect") %>% droplevels()
portland.care <- portland.combined %>% filter(DN_AF1>85 & DN_AF1<88.5) %>% mutate(Category="Extra Care") %>% droplevels()
portland.concern <- portland.combined %>% filter(DN_AF1>88.5)%>% mutate(Category="Most Concern") %>% droplevels()
portland.combined.cat <- bind_rows(list(portland.protect,portland.care,portland.concern))
seattle.protect <- seattle.combined.back %>% filter(DN_AF1<85) %>% mutate(Category="Protect") %>% droplevels()
seattle.care <- seattle.combined.back %>% filter(DN_AF1>85 & DN_AF1<88.5) %>% mutate(Category="Extra Care") %>% droplevels()
seattle.concern <- seattle.combined.back %>% filter(DN_AF1>88.5)%>% mutate(Category="Most Concern") %>% droplevels()
seattle.combined.cat <- bind_rows(list(seattle.protect,seattle.care,seattle.concern))
87 trees in Seattle did not have UHI data. 1 tree in Portland did not have UHI data.
cities <- full_join(seattle.combined.cat,portland.combined.cat,by = join_by(OBJECTID, DBH, DN_AF1, lat, lon, city, city.space,GlobalID,Category))
summary <- cities %>% group_by(city,city.space,Category) %>% summarize(n=n(),meanAF=mean(DN_AF1,na.rm=TRUE),n_AF_na=sum(is.na(DN_AF1)))
## `summarise()` has grouped output by 'city', 'city.space'. You can override
## using the `.groups` argument.
summary
## # A tibble: 12 × 6
## # Groups: city, city.space [4]
## city city.space Category n meanAF n_AF_na
## <chr> <chr> <chr> <int> <dbl> <int>
## 1 Portland Park Extra Care 259 87.7 0
## 2 Portland Park Most Concern 609 89.1 0
## 3 Portland Park Protect 96 83.4 0
## 4 Portland Street Extra Care 737 87.6 0
## 5 Portland Street Most Concern 867 89.0 0
## 6 Portland Street Protect 110 83.5 0
## 7 Seattle Park Extra Care 692 87.5 0
## 8 Seattle Park Most Concern 114 89.1 0
## 9 Seattle Park Protect 4 83.4 0
## 10 Seattle Street Extra Care 1560 87.2 0
## 11 Seattle Street Most Concern 197 89.1 0
## 12 Seattle Street Protect 36 84.1 0
ggplot(summary,aes(n,city.space,fill=Category))+geom_col(position=position_dodge(),alpha=0.7) +facet_wrap(~city) +theme_bw() + scale_fill_manual(name="Category",values=c("#7fcdbb","#fe9929","#DDA0DD")) +labs(x="Number of Trees",y="Tree Inventory")
summary <- cities %>% group_by(city,Category) %>% summarize(n=n(),meanAF=mean(DN_AF1,na.rm=TRUE),n_AF_na=sum(is.na(DN_AF1)))
## `summarise()` has grouped output by 'city'. You can override using the
## `.groups` argument.
summary
## # A tibble: 6 × 5
## # Groups: city [2]
## city Category n meanAF n_AF_na
## <chr> <chr> <int> <dbl> <int>
## 1 Portland Extra Care 996 87.6 0
## 2 Portland Most Concern 1476 89.1 0
## 3 Portland Protect 206 83.5 0
## 4 Seattle Extra Care 2252 87.3 0
## 5 Seattle Most Concern 311 89.1 0
## 6 Seattle Protect 40 84.0 0
summary <- portland.combined.cat %>% group_by(city.space,Category) %>% summarize(n=n(),meanAF=mean(DN_AF1,na.rm=TRUE),n_AF_na=sum(is.na(DN_AF1)))
## `summarise()` has grouped output by 'city.space'. You can override using the
## `.groups` argument.
summary
## # A tibble: 6 × 5
## # Groups: city.space [2]
## city.space Category n meanAF n_AF_na
## <chr> <chr> <int> <dbl> <int>
## 1 Park Extra Care 259 87.7 0
## 2 Park Most Concern 609 89.1 0
## 3 Park Protect 96 83.4 0
## 4 Street Extra Care 737 87.6 0
## 5 Street Most Concern 867 89.0 0
## 6 Street Protect 110 83.5 0
ggplot(summary,aes(n,city.space,fill=Category))+geom_col(position=position_dodge(),alpha=0.7) +theme_bw() + scale_fill_manual(name="Category",values=c("#7fcdbb","#fe9929","#DDA0DD")) +labs(x="Number of Trees",y="Tree Inventory")
portbb <- c(left = min(portland.combined.cat$lon),
bottom = min(portland.combined.cat$lat),
right = max(portland.combined.cat$lon),
top = max(portland.combined.cat$lat))
portmap <- get_map(portbb, zoom = 11, scale = 2, maptype="terrain",source="google")
## ! Bounding box given to Google - spatial extent only approximate.
## ℹ <https://maps.googleapis.com/maps/api/staticmap?center=45.543068,-122.632381&zoom=11&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx>
portland.map <- ggmap(portmap) + geom_point(data = portland.combined.cat, aes(x = lon, y = lat,fill=DN_AF1), color = "black",pch=21, size = 3) + theme_minimal() +scale_fill_viridis_c(option = "inferno")+labs(title="Portland",x="Longitude",y="Latitude",fill="Afternoon\nTemp (F)") +theme(plot.title = element_text(size = 14, hjust = .5,face = "bold.italic"))
portland.map
portland.map.cat <- ggmap(portmap) + geom_point(data = portland.combined.cat, aes(x = lon, y = lat,fill=Category), color = "black",pch=21, size = 3) + theme_minimal() +scale_fill_manual(name="Category",values=c("#7fcdbb","#fe9929","#DDA0DD"))+labs(title="Portland",x="Longitude",y="Latitude",fill="Conservation\nCategory") +theme(plot.title = element_text(size = 14, hjust = .5,face = "bold.italic"))
portland.map.cat
summary <- seattle.combined.cat %>% group_by(city.space,Category) %>% summarize(n=n(),meanAF=mean(DN_AF1,na.rm=TRUE),n_AF_na=sum(is.na(DN_AF1)))
## `summarise()` has grouped output by 'city.space'. You can override using the
## `.groups` argument.
summary
## # A tibble: 6 × 5
## # Groups: city.space [2]
## city.space Category n meanAF n_AF_na
## <chr> <chr> <int> <dbl> <int>
## 1 Park Extra Care 692 87.5 0
## 2 Park Most Concern 114 89.1 0
## 3 Park Protect 4 83.4 0
## 4 Street Extra Care 1560 87.2 0
## 5 Street Most Concern 197 89.1 0
## 6 Street Protect 36 84.1 0
ggplot(summary,aes(n,city.space,fill=Category))+geom_col(position=position_dodge(),alpha=0.7) +theme_bw() + scale_fill_manual(name="Category",values=c("#7fcdbb","#fe9929","#DDA0DD")) +labs(x="Number of Trees",y="Tree Inventory")
seabb <- c(left = min(seattle.combined.cat$lon),
bottom = min(seattle.combined.cat$lat),
right = max(seattle.combined.cat$lon),
top = max(seattle.combined.cat$lat))
seamap <- get_map(seabb, zoom = 11, scale = 2, maptype="terrain",source="google")
## ! Bounding box given to Google - spatial extent only approximate.
## ℹ <https://maps.googleapis.com/maps/api/staticmap?center=47.616324,-122.334218&zoom=11&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx>
seattle.map <- ggmap(seamap) + geom_point(data = seattle.combined.cat, aes(x = lon, y = lat,fill=DN_AF1), color = "black",pch=21, size = 3) + theme_minimal() +scale_fill_viridis_c(option = "inferno")+labs(title="Seattle",x="Longitude",y="Latitude",fill="Afternoon\nTemp (F)") +theme(plot.title = element_text(size = 14, hjust = .5,face = "bold.italic"))
seattle.map
seattle.map.cat <- ggmap(seamap) + geom_point(data = seattle.combined.cat, aes(x = lon, y = lat,fill=Category), color = "black",pch=21, size = 3) + theme_minimal() +scale_fill_manual(name="Category",values=c("#7fcdbb","#fe9929","#DDA0DD"))+labs(title="Seattle",x="Longitude",y="Latitude",fill="Conservation\nCategory") +theme(plot.title = element_text(size = 14, hjust = .5,face = "bold.italic"))
seattle.map.cat
seattle.map <- seattle.map + theme(legend.position = "none",axis.title.x = element_blank())
seattle.map.cat <- seattle.map.cat + theme(legend.position = "none",plot.title = element_blank())
portland.map <- portland.map +theme(axis.title.x = element_blank(),axis.title.y = element_blank())
portland.map.cat <- portland.map.cat +theme(plot.title = element_blank(),axis.title.y = element_blank())
#+ theme(legend.position = "none",,)
(seattle.map | portland.map) / (seattle.map.cat | portland.map.cat)